package three.pipeInputOutput.test;

import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;

import three.pipeInputOutput.extthread.ThreadRead;
import three.pipeInputOutput.extthread.ThreadWrite;
import three.pipeInputOutput.service.ReadData;
import three.pipeInputOutput.service.WriteData;

public class Run {
	
	public static void main(String[] args) {
		WriteData writeData = new WriteData();
		ReadData readData = new ReadData();
		
		PipedInputStream inputStream = new PipedInputStream();
		PipedOutputStream outputStream = new PipedOutputStream();
		
		try {
			outputStream.connect(inputStream);
			
			ThreadRead threadRead = new ThreadRead(readData,inputStream);
			threadRead.start();
			
			Thread.sleep(2000);
			
			ThreadWrite threadWrite = new ThreadWrite(writeData,outputStream);
			threadWrite.start();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		
		
	}
	
	
}
